package com.example.demo.config;

import org.noear.solon.core.AppClassLoader;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;

/**
 * @author noear
 * @since 2.8
 */
public class ObjectInputStreamEx extends ObjectInputStream {
  public ObjectInputStreamEx(InputStream in) throws IOException {
    super(in);
  }

  protected ObjectInputStreamEx() throws IOException, SecurityException {
    super();
  }

  @Override
  protected Class<?> resolveClass(ObjectStreamClass desc)
      throws IOException, ClassNotFoundException {
    String name = desc.getName();
    try {
      return Class.forName(name, false, AppClassLoader.global());
    } catch (ClassNotFoundException ex) {
      throw ex;
    }
  }
}
